package com.tiepbm.cucphamgiadinh.util;


import tiepbm.app.util.memory.MyPreference;
import android.content.Context;

public class MyPreferenceManager {

	private static MyPreferenceManager instance;
	private MyPreference preference;

	private MyPreferenceManager(Context context) {
		this.preference = MyPreference.getInstance(context);
	}

	public static MyPreferenceManager getInstance(Context context) {
		if (instance == null) {
			instance = new MyPreferenceManager(context);
		}
		return instance;
	}

	/**
	 * clear values
	 */
	public void clear() {
		preference.clear();
	}


	/**
	 * Save current chapter reading
	 */
	public void setChaper(int chapter) {
		preference.putInt("chapter", chapter);
	}

	/**
	 * Get current chapter
	 */
	public int getChapter() {
		int chapter = preference.getInt("chapter", 1);
		
		return chapter;
	}
	/**
	 * Save current chapter reading
	 */
	public void setChaperMax(int chapter) {
		preference.putInt("chaptermax", chapter);
	}

	/**
	 * Get current chapter
	 */
	public int getChapterMax() {
		int chapter = preference.getInt("chaptermax", 1);
		
		return chapter;
	}
}
